<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
	<?php
	if(isset($_POST['ok']))
	{
	$u=$p="";
	if($_POST['username'] == NULL)
	{
	echo "Please enter your username<br />";
	}
	else
	{
	$u=$_POST['username'];
	}
	if($_POST['password'] == NULL)
	{
	echo "Please enter your password<br />";
	}
	else
	{
	$p=$_POST['password'];
	}
	if($u && $p)
	{
	$conn=mysql_connect("localhost","root","") or die("ket noi khong thanh cong");
	mysql_select_db("DTDD",$conn);
	$sql="select * from login where Username='".$u."' and Password='".$p."'";
	$query=mysql_query($sql);
	if(mysql_num_rows($query) == 0)
	{
	echo "Username or password is not correct, please try again";
	}
	else
	{
	$url = "http://localhost/WebDTDD/index.php";
	echo "<meta http-equiv='refresh' content='0;url=$url' />";
	}
	}
	}
	?>

<form action='login.php' method='post'>
Username: <input type='text' name='username' size='25' /><br />
Password: <input type='password' name='password' size='25' /><br />
<input type='submit' name='ok' value='Dang Nhap' />
</form>

</body>
</html>